package m4d2;

import java.util.stream.Stream;

//limit 截取前n个元素
//skip 跳过前几个元素
//concat  组合两个流
public class slimit {
    public static void main(String[] args) {
        Stream<String> stream = Stream.of("1", "22", "333", "4444");

        Stream<String> stream1 = stream.limit(3);

        stream1.forEach(n-> System.out.println(n));
        System.out.println("============");


        Stream<String> stream2 = Stream.of("1", "22", "333", "4444");

        Stream<String> stream3 = stream2.skip(1);

        stream3.forEach(s-> System.out.println(s));
        System.out.println("=================");


        Stream<String> stream4 = Stream.of("1", "22", "333", "4444");
        Stream<String> stream5 = Stream.of("aa", "bb", "cc", "dd");
        Stream<String> stream6 = Stream.concat(stream4,stream5);
        stream6.forEach(s-> System.out.println(s));
    }
}
